//
//  HLLNavView.m
//  PhotoHLL
//
//  Created by mac on 2017/9/19.
//  Copyright © 2017年 yangweiwei. All rights reserved.
//

#import "HLLNavView.h"

#define StateHigh 22
#define NavHigh 42
@interface HLLNavView(){


}
@property (nonatomic, strong) UIImageView *iconImgView;
@property (nonatomic, strong) UIImageView *titleImgView;
@property (nonatomic, strong) UIButton *searchBtn;
@end

@implementation HLLNavView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)normalNavView{

    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.iconImgView];
    [self addSubview:self.titleImgView];
    [self addSubview:self.searchBtn];
}
- (UIImageView *)iconImgView{

    if (!_iconImgView) {
        _iconImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, StateHigh, NavHigh, NavHigh)];
        _iconImgView.image = [UIImage imageNamed:@"icon"];
    }
    return _iconImgView;
}
- (UIImageView *)titleImgView{

    if (!_titleImgView) {
        UIImage *image = [UIImage imageNamed:@"app_name_r"];
        NSInteger wide = image.size.width * NavHigh / image.size.height;
        _titleImgView = [[UIImageView alloc] initWithFrame:CGRectMake((KWidth - wide) / 2, StateHigh, wide, NavHigh)];
        _titleImgView.image = image;
    }
    return _titleImgView;
}
- (UIButton *)searchBtn{

    if (!_searchBtn) {
        _searchBtn = [[UIButton alloc] initWithFrame:CGRectMake(KWidth - NavHigh - 10, StateHigh, NavHigh, NavHigh)];
        [_searchBtn setImage:[UIImage imageNamed:@"search_r"] forState:Normal];
        [_searchBtn addTarget:self action:@selector(searchButtonAction) forControlEvents:TouchUPInside];
    }
    return _searchBtn;
}
- (void)searchButtonAction{

    if ([self.delegate respondsToSelector:@selector(searchButtonAction)]) {
        [self.delegate searchButtonAction];
    }
}
@end
